package ch.unisi.inf.gui.action;

import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;

import javax.swing.AbstractAction;
import javax.swing.JFrame;
import javax.swing.JList;

import ch.unisi.inf.engine.Image;
import ch.unisi.inf.gui.MainFrame;
import ch.unisi.inf.viewer.MainImgViewerPanel;

	

public class ListChangeAction extends MouseAdapter {
	private MainFrame mainFrame;
	private JList list;
	private MainImgViewerPanel thumbnail;
	private ArrayList<Image> holydaysImages;
	private ArrayList<Image> dogImages;
	private ArrayList<Image> imageList;
	private ArrayList<Image> carList;
	
	public ListChangeAction(final MainFrame mainFrame, final ArrayList<Image> holydaysImages, final ArrayList<Image> dogImages, final ArrayList<Image> imageList, final ArrayList<Image> carList, final JList list){
		this.mainFrame = mainFrame;
		this.holydaysImages = holydaysImages;
		this.dogImages = dogImages;
		this.list = list;
		this.imageList = imageList;
		this.carList = carList;
		
		this.list = list;
	}
	public void mouseClicked(MouseEvent e) {
		
		if(e.getClickCount() == 1){
			int index = list.locationToIndex(e.getPoint());
			Object o = list.getModel().getElementAt(index);
			
			if(index == 0){
				thumbnail = new MainImgViewerPanel(imageList, mainFrame);
				mainFrame.setThumbnailsFrame(thumbnail);
			}if(index == 1){
				thumbnail = new MainImgViewerPanel(holydaysImages, mainFrame);
				mainFrame.setThumbnailsFrame(thumbnail);
			}if(index == 2){
				thumbnail = new MainImgViewerPanel(dogImages, mainFrame);
				mainFrame.setThumbnailsFrame(thumbnail);		
			}if(index == 3){
				thumbnail = new MainImgViewerPanel(carList, mainFrame);
				mainFrame.setThumbnailsFrame(thumbnail);
			}
			else{
				
			}	
		}
	}

	public void mouseEntered(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	public void mousePressed(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	

}
